#!/usr/bin/env python

import json
from notify import notify
from time import sleep
import os

os.system('./run_spider.sh')

with open('./date.json') as json_data:
    file_content = json.load(json_data)

curr_date = file_content[0]['date']


while True:
    os.system('./run_spider.sh')
    with open('./date.json') as json_data:
        file_content = json.load(json_data)

    new_date = file_content[0]['date']
    month = int(new_date.split('-')[1])
    day = int(new_date.split('-')[2])

    # Less than 2nd may and later than 11th april.
    #
    if ((month == 5 and day < 2) or (month == 4 and day >= 11)) and (new_date != curr_date):
        notify('New date!\n' + new_date)
        curr_date = new_date

    # Sleep for 6 min.
    #
    sleep(360)


# EOF
# vim: set tabstop=4 shiftwidth=4 expandtab :
